<?php

namespace sms;

use ReflectionException;

class ClassAttr
{
    public static function smsClassStat()
    {
        return [
            SmsConfigEnum::ALI_SMS => 'sms\AliSms'
        ];
    }

    /**
     * @param $type
     * @param $class
     * @param array $params
     * @param bool $needInstance
     * @return false|mixed|object|null
     * @throws ReflectionException
     */
    public static function initClass($type, $class, array $params = [], bool $needInstance = false)
    {
        if (!array_key_exists($type, $class)) {
            return false;
        }
        $className = $class[$type];
        return $needInstance ? (new \ReflectionClass($className))->newInstanceArgs($params) : $className;
    }
}